<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<script src="templates/tpl_automobil/js/jquery.validate.js" type="text/javascript"></script>
 <?php	if(isset($this->message)){
		$this->display('message');
	}
?>  
<form action="<?php echo JRoute::_( 'index.php', true, $this->params->get('usesecure')); ?>" method="post" name="com_form_register" id="com_form_register">
<div class="w739 float_right" id="register"> 
 <div class="tt  p5t">Registering</div>
        <div class="box_gude p10l p15t p30b">
          <div class="form_tilmelding3 m100l w462" style="width:420px;">
          	<label>Dit fulde navn:<span>*</span></label>
            <input name="name" id="name" type="text" class="txt_tilmelding w390" value="" />
            <label>E-mail:<span>*</span></label>
            <input style="float: left;" name="email" id="email" type="text" class="txt_tilmelding w390" value="" onblur="setUsername(this.value)" />
            <label>Password:<span>*</span></label>
            <input style="float: left;" name="password" id="password" type="password" class="txt_tilmelding w390" value="" />
            <label>Gentag password:<span>*</span></label>
            <input name="password2" id="password2" type="password" class="txt_tilmelding w390" value="" />
            <label>Fima-navn:</label>
            <input name="company" id="company" type="text" class="txt_tilmelding w390" value="" />
            <label>CVR-nr:</label>
            <input name="cvr" type="text" class="txt_tilmelding w390" value="" />
            <label>Adresse:<span>*</span></label>
            <input name="address" id="address" type="text" class="txt_tilmelding w390" value="" />
            <label>Postnr.<span>*</span></label>
            <input name="code" id="code" type="text" class="txt_tilmelding" style="width: 80px;" maxlength="4" value="" />
            <label id="w40"  style="text-align:center; line-height:29px;">By:<span>*</span></label>
            <input name="city"  type="text" class="w171 txt_tilmelding" id="city" value="" />
            <label>Telefon:</label>
            <input name="phone" type="text" class="txt_tilmelding w390" value="" />
            <div class="cb"></div>
            <p class="p5t p5b">Indtast nedenstående kode i tekst-boksen </p>           
            <?php $string = md5(microtime() * mktime());$text = substr($string, 0, 5);?>
            <input type="text" name="capcha11" id="capcha11" style="display:none;" value="<?php echo $text;?>"/>     
            <label><img width="60" height="36" src="index.php?option=com_captcha&text=<?php echo $text; ?>" alt="<?php echo $text; ?>" /></label>
          <br/><br/><br />   
          <input size="20" class="txt_tilmelding w390" maxlength="5"  type="text" name="capcha12" id="capcha12"  value="Skriv ordene her:"  onfocus="this.value = ''"/>
          <a onclick="send_contact();" href="javascript:void(0);"><img src="templates/tpl_automobil/images/bt_registrerer.jpg"/></a></div>      
          <input type="submit" value="send_register" id="send_register" name="submit" style="display:none;" />
       </div> 
    </div> 
 
   	<input type="hidden" name="username" id="username" value="" />
	<input type="hidden" name="task" value="register_save" />
	<input type="hidden" name="id" value="0" />
	<input type="hidden" name="gid" value="0" />
	<?php echo JHTML::_( 'form.token' ); ?>
     </form>

<script type="text/javascript">
	$(document).ready(function(){
	
    send_contact=function(){
		if($('#name').val() == ""){
			$('#alert').html('Udfyld venligst fulde navn');
			$('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('name');
			return false;
		}
			
	     if($('#email').val() == ""){
			$('#alert').html('Udfyld venligst email');
			$('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('email');
			return false;	
          }
          else{
			if(!isEmail($('#email').val())){
				$('#alert').html('Indtast en gyldig email');
				$('#backoverlay').show();
				$('#show_popup').show();
				$('#s_focus').html('email');
				return false; 
			}
          }
            
    	if($('#password').val() == ""){
			$('#alert').html('Udfyld venligst adgangskode');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('passwd');
			return false;	
		}
		if($('#password2').val() == ""){
			$('#alert').html('Udfyld venligst gentag password');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('password2');
			return false;	
		}
        if($('#password2').val()!= $('#password').val()){
			$('#alert').html('Adgangskode/Gentag adganskode er ikke gyldig');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('password2');
			return false;	
		}
		
		if($('#code').val() == ""){
			$('#alert').html('Udfyld venligst postnr.');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('code');
			return false;	
            
        }
		 	
        if($('#address').val() == ""){
			$('#alert').html('Udfyld venligst adresse');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('address');
			return false;	
            
        }
       
        if($('#city').val() == ""){
			$('#alert').html('Udfyld venligst by');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('city');
			return false;	
            
        }
        if($('#capcha11').val()!=$('#capcha12').val()){
           $('#alert').html('Venligst indtast sikkerhedskode');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('capcha12');
			return false;
        }  
         $('#send_register').click();
        return true;
	};
    
    isEmail=function(string) {
		if (string.search(/^\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
		else return false;
    };
    });

</script>
<!-- catch error from server -->
 <script type="text/javascript">
          jQuery(document).ready(function(cash) {
            jQuery("#email").attr("value","<?php echo @JRequest::getVar("username","");?>");
           if(jQuery("#system-message  ul li").html()!=null)
              {
                $('#alert').html(jQuery("#system-message  ul li").html());
                $('#backoverlay').show();
		      	$('#show_popup').show();
        	  } 
           });
</script>
<script>
function send_register(){
    document.getElementById('send_register').click();
}
function setUsername(username){
	$("#username").val(username);
}
</script>